    package my.li.zhcslandfront.controller;

    import Vo.Land;
    import Vo.Store;

    import land.StoreFeiginInterface;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;
    import page.PageBean;
    import util.JsonResult;

    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpSession;
    import java.util.ArrayList;
    import java.util.List;

    @Controller
    @RequestMapping("/store")
    public class StoreController {
        private StoreFeiginInterface feiginInterface;

        @RequestMapping("/")

        public String test(HttpSession session){
            session.setAttribute("pagebean",new PageBean());
            session.setAttribute("stores",new ArrayList<Store>());
            return "store_manager";
        }
        @RequestMapping("/getAll")
        public String getAllMes(PageBean pageBean, HttpServletRequest request){
            HttpSession session = request.getSession();
            session.setAttribute("pagebean",pageBean);
            List<Store> stores = new ArrayList<>();
//                    = feiginInterface.queryAll(pageBean);
            session.setAttribute("stores",stores);
            return "store_manager";
        }

        @RequestMapping("/getById")
        @ResponseBody
        public JsonResult queryById(Store store){
//            if(store!=null){
//                feiginInterface.queryByStroeId(store);
                System.out.println("queryById :  "+store);
                return JsonResult.successWithoutData();
//            }else {
//                return JsonResult.failed("失败");
//            }

        }


        @RequestMapping("/add")
        @ResponseBody
        public JsonResult addStore(Store store){
//            boolean b = feiginInterface.addStore(store);
            System.out.println("add : "+store);
            return JsonResult.successWithoutData();
        }

        @RequestMapping("store_add")
        public String edit(Store store,HttpServletRequest request){
            System.out.println("edit" +store);
            //查询回显
//            boolean b = feiginInterface.queryByStroeId(store);
            request.setAttribute("edit",store);
            return "store_add";
        }

        @RequestMapping("deleteById")
        @ResponseBody
        public JsonResult deleteById(Store store){
//            feiginInterface.deleteById(store);
            System.out.println("delete"+store);
            return JsonResult.successWithoutData();
        }


    }
